<template>
	<view>
		<view class="content">
			<image src="../../static/images/logo.png" class="logo"></image>
			<view class="loginBtnView">
				<!-- #ifdef MP-WEIXIN -->
				<button  hover-class="none" open-type="getUserInfo" withCredentials="true" lang="zh_CN" @getuserinfo="login" class="loginBtn">登录</button>
				<!-- #endif -->
				<!-- #ifdef MP-TOUTIAO -->
				<button  hover-class="none" @click="login" class="loginBtn">登录</button>
				<!-- #endif -->
			</view>
		</view>
	</view>
	
</template>
<script>
	export default {
		data() {
			return {
			}
		},
		methods: {
			//登录
			async login(){
				const loginData = await this.$s.uniApi.loginData();
				if(loginData.type){
					const res = await this.$s.model.user.login(loginData)
					await this.$s.uniApi.setStorage('token',res.token)
					await this.$s.uniApi.setStorage('token_type',res.token_type)
					await this.$s.uniApi.navigateBack({})
				}
				
			}
			
		}
	};
</script>

<style lang="scss" scoped>
@import 'login.scss';
</style>
